const {ccclass, property} = cc._decorator;

@ccclass
export default class RenderNodeComponent extends cc.Component {

    public start() {

        setTimeout(() => {
            const camera: cc.Camera =  this.node.addComponent(cc.Camera);

            const texture = new cc.RenderTexture();
            // 如果截图内容中不包含 Mask 组件，可以不用传递第三个参数
            texture.initWithSize(this.node.width, this.node.height, 36168);
            camera.targetTexture = texture;
            camera.render(this.node);
            const spriteNode: cc.Node = new cc.Node();
            const sprite: cc.Sprite =  spriteNode.addComponent(cc.Sprite);
            const spriteFram: cc.SpriteFrame = new cc.SpriteFrame(texture);
            sprite.spriteFrame = spriteFram;
            spriteNode.setScale(1, -1);
            this.node.parent.addChild(spriteNode);
            spriteNode.position = this.node.position;
            this.node.destroy();
        }, 500);

        // cc.dynamicAtlasManager.showDebug(true);
    }

}
